<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ page import="java.util.*"%>
<%
	Map sessionSet = (Map) session.getServletContext().getAttribute("sessions");
%>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>bomc系统首页</title>
    <jsp:include page="/common/link.jsp"></jsp:include>
    <link rel="stylesheet" type="text/css"
          href="<%=application.getContextPath()%>/njs/basd/easyui/jquery-easyui-1.3.3/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css"
          href="<%=application.getContextPath()%>/njs/basd/easyui/jquery-easyui-1.3.3/themes/icon.css" />
    <script type="text/javascript"
            src="<%=application.getContextPath()%>/njs/basd/easyui/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
    <link rel="stylesheet" type="text/css"
          href="<%=application.getContextPath()%>/nresources/basd/itsm/jquery.hiAlerts.css" />
    <script type="text/javascript"
            src="<%=application.getContextPath()%>/njs/basd/hiAlerts/jquery.hiAlerts-min.js"></script>
    <link rel="stylesheet" type="text/css"
          href="<%=application.getContextPath()%>/nresources/basd/itsm/itilManage.css" />
    <script type="text/javascript"
            src="<%=application.getContextPath()%>/njs/basd/jcarousellite_1.0.1.pack.js"></script>
    <jsp:include page="/WEB-INF/ibnms/common/ztree.jsp"></jsp:include>
</head>

<body>
	<div class="header clearfix">
		<div class="left-panel fl clearfix">
			<a class="logo" href="#"><img src="<%=application.getContextPath()%>/nresources/ued/images/logo.jpg" /></a>
		</div>
		<div class="right-panel clearfix">
			<div class="right-panel-t">
            	<div class="fl"><p class="logoTitle"><a href="#"><s:property value="filter.PROJECT_NAME" /></a></p></div>
            	<div class="fr">
					<ul class="blue-link">
						<li>
							<a system_id='mainpage' class="on" href="#">首页</a>
						</li>
						<s:iterator value="subSystemList" var="subSystems" status="st">
							<li>
								<a system_id='<s:property value="#subSystems.MODULE_ID"/>' system_path='<s:property value="#subSystems.MODULE_PATH"/>'
									href="#" module_target='<s:property value="#subSystems.MODULE_TARGET"/>'><s:property value="#subSystems.MODULE_NAME" /> </a>
							</li>
						</s:iterator>
					</ul>
				</div>
				<div class="clear"></div>
			</div>
			<div class="right-panel-b">
            <div id="time" class="actualTime" style="display:none"></div>
            <div id="shotCutList" class="fr" style="float:left;">
                <div class="move-right" style="float:right;">
                    <a style="cursor: pointer"><img src="nresources/ued/images/right.png" style="margin-top:4px"/></a>
                </div>
                <div class="move-left" style="float:left;">
                    <a style="cursor: pointer"><img src="nresources/ued/images/left.png" style="margin-top:4px"/></a>
                </div>
            </div>
	            <div class="fr">
	            	<div class="end"><a href="logout.do">退出</a></div>
                    <div class="end">
                        <a href="#" id="shortmenuBtnTop">快捷菜单</a>
                    </div>
	            	<div class="end"><a href="#" style="cursor:text"><s:property value="currentUser.NAME" /></a></div>
	            	<div class="end"><a href="#" style="cursor:text">当前在线人数：<%=sessionSet.size()%>人</a></div>
	            </div>
	             <div class="clear"></div> 
	         </div>
		</div>
	</div>
	<div class="container container-2">
		<div id="layout">
			<div position="left" class="side-panel">
				<div ref="indexpage" class="side-tt">
					<h2>
						<span class="side-text">快捷栏</span><span
							class="l-layout-header-toggle"></span>
					</h2>
				</div>
				<div class="side-content">
					<div data-role="accordion" data-rel="active">

					</div>
				</div>
			</div>
			<div position="center" class="main-panel">
				<div class="tabspage">
					<span class="scrollPrev tabspage-pre"></span>
					<span class="scrollNext tabspage-next"></span>
					<div title="首页" tabid="indexpage" lselected="true">
						<iframe class="framepage mgt-5" src="<%=application.getContextPath()%>/panel.do" id="panelfrm"
							frameborder="0" allowtransparency="true" hspace="0" vspace="0"
							scrolling="auto"></iframe>
					</div>
				</div>
			</div>
		</div>
		<!--<div class="foot-panel"><p>中国移动通信集团</p></div>-->
	</div>

	<div id="sortcutMenu" style="display: none">
		<p ref='shortcut' class="side-list-2">
			<span><img src="<%=application.getContextPath()%>/nresources/ued/images/icon-b.png" /><a
				href="#">我的门户</a> </span>
		</p>
		<ul ref='shortcut' class="side-list-ul">
			<li>
				<a href="#" class="modal_box_iframe"><img width="20px"
						height="20px" src="<%=application.getContextPath()%>/nresources/ued/images/image-5.png" />个性化设置</a>
			</li>
			<li>
            <a href="#" class="person_record"><img width="20px"
                                                   height="20px" src="<%=application.getContextPath()%>/nresources/ued/images/image-5.png" />通讯录</a>
            </li>
            <li>
				<a href="#" id="msgCenter" class="showMessager"><img width="20px" height="20px"
						src="<%=application.getContextPath()%>/nresources/ued/images/image-5.png" />消息中心</a>
			</li>
			<li>
				<a href="#" id="onlineServer" class="onlineService"><img width="20px" height="20px"
						src="<%=application.getContextPath()%>/nresources/ued/images/image-5.png" />在线客服</a>
			</li>
            <li style="display: none" id='changeUserli'>
                <a href="#" id="changeUser" class="changeUser"><img width="20px" height="20px"
                        src="<%=application.getContextPath()%>/nresources/ued/images/image-5.png" />切换用户</a>
            </li>
            <li>
                <a href="#" id="shortmenuBtn"><img width="20px" height="20px"
                         src="<%=application.getContextPath()%>/nresources/ued/images/image-5.png" />快捷菜单</a>

                <div id="shortmenuShow" class="easyui-menu" style="width: 100px;">
                </div>
            </li>
		</ul>
		<p ref='shortcut' class="side-list-2">
			<span><img src="<%=application.getContextPath()%>/nresources/ued/images/icon-b.png" /><a
				href="#">系统服务热线</a> </span>
		</p>
	</div>
	<div id="short_win" title="快捷菜单设置" style="display:none">  
       	<div class="form-wrapper">
			<form id="shortcutEditForm" method="post">
				<input type="hidden" name='shortcutForm.module_id' />
				<input type="hidden" name='shortcutForm.login_id' value="<s:property value="currentUser.LOGIN_ID" />" />
				<table class="table-03">
					<tr>
						<td> 
							分类：
						</td>
						<td>
							<select id="shortcutTypeSelect" name="shortcutForm.type_id" style="width:100px">
							</select>
							<!-- 
								<a id="shortcut-create" href="javascript:void(0)" >新建</a>
								<div id="addShortcutType" style="display:none">
									<input id="shortcutName" type="text" />
									<input id="saveShortcutType" type="button" class="btn-style02" align="middle" value="保存" />
								</div>
							 -->
						</td>
					</tr>
					<tr>
						<td> 
							快捷名称:
						</td>
						<td>
							<input type="text" name="shortcutForm.shortcut_name" value="" />
						</td>
					</tr>
					<tr>
						<td> 
							快捷路径:
						</td>
						<td>
							<input type="text" name="shortcutForm.shortcut_path" value="" readonly/>
						</td>
					</tr>
				</table>
				<div class="block03">
					<a id="shortcut-submit" href="javascript:void(0)"
						class="easyui-linkbutton">保存</a>
				</div>
			</form>
		</div>
    </div>  
    <div id="mask" style="display:none" class="mask"></div>
	<div id="personalize"></div>
	<jsp:include page="uedScript.jsp"></jsp:include>
	<jsp:include page="messager.jsp"></jsp:include>

    <jsp:include page="../main2/news.jsp"></jsp:include>
    <jsp:include page="../main2/news2.jsp"></jsp:include>

</body>
</html>
<script type="text/javascript">
	var tab = null;
	var loginId = '<s:property value="currentUser.LOGIN_ID" />';
	var messageSetting;
	var shortcutMenus;
    var clientwidth = 0;
    var  preAttr = location.pathname.split("/");
    var varPreName = preAttr[preAttr.length-1] + "_";
    var ShortcutDisplay = "ShortcutDisplay";
    function storeLocal(name,value){
        store.set(varPreName+name,value);
    };
    function getLocalStore(name){
        return store.get(varPreName+name);
    }
    function delLocalStore(name){
        return store.remove(varPreName+name);
    }

	$(document).ready(function(){
        if($.browser.msie && $.browser.version=="7.0"){
            $(".l-accordion-toggle,.center_close").live("click",function(){
                setTimeout(function(){
                    $(".ztree").find("li").css("width",$(".ztree").find("li").css("width"));
                },1000);
                setTimeout(function(){
                    $(".ztree").find("li").css("width",$(".ztree").find("li").css("width"));
                },5000);
            })
        }
        var roleStr = '${currentUser.roles}';
        if(roleStr && (roleStr.indexOf("1050")>=0 || roleStr.indexOf("1509")>=0)){
            $("#changeUserli").show();
        }
        var ShortcutDisplayTip = getLocalStore(ShortcutDisplay)||"";
        $("#shortcut-create").click(function(){
			//window.showModalDialog("<%=application.getContextPath()%>/shorcut/loadShortcutManange.do","","help:no;scroll:no;status:no;dialogHeight:500px;dialogWidth:400px");
			$("#addShortcutType").show();
			$("#typeName").val('');
		});
		$("saveShortcutType").click(function(){
			var name = $("#shortcutName").val();
			alert(name);
			if(name!=""){
				name = encodeURI(name);   
				name = encodeURI(name); 
				$.ajax({
					url:"<%=application.getContextPath()%>/shorcut/saveType.do?shortcutTypeForm.type_name="+name,
					type:"post",
					success:function(data){
						var $shortmenuShow = $("#shortmenuShow");
						var $shortcutTypeSelect = $("#shortcutTypeSelect");
						$shortcutTypeSelect.empty();
						$shortcutTypeSelect.append("<option value=''>无</option>");
						$.each(msg,function(idx,shortcutType){
							$shortcutTypeSelect.append("<option value='"+shortcutType.type_id+"'>"+shortcutType.type_name+"</option>");
						});
					}
				});
			}
		});
		$("#shortcut-submit").click(function(){
			var user = $("input[name='shortcutForm.login_id']").val();
			var mId = $("input[name='shortcutForm.module_id']").val();
			
			var shortName = $("input[name='shortcutForm.shortcut_name']").val();
			var shortPath = $("input[name='shortcutForm.shortcut_path']").val();
			
			var $typeObj = $("select[name='shortcutForm.type_id'] option:selected");
			var typeId = $typeObj.val();
			if(typeId==""){
				$('#shortmenuShow').menu('appendItem', {
					text: '<a moduleId="'+mId+'" style="cursor: hand;" path="'+shortPath+'">'+shortName+'</a>',
					iconCls: 'icon-tip',
					onclick:function(){
						var $clickObj = $(this).find("a");
						// 添加快捷菜单单击事件
						var tabId = $clickObj.attr("moduleId");
						$(".tabspage").removeClass("tabspage-2");
				    	tab.addTabItem({tabid : tabId,text: $clickObj.text(), url: $clickObj.attr("path") });
					}
				});
			}else{
				var typeName = $typeObj.text();
				var item = $('#shortmenuShow').menu('findItem', typeName);
				$('#shortmenuShow').menu('appendItem', {
					parent: item.target,  // the parent item element
					text: '<a moduleId="'+mId+'" style="cursor: hand;" path="'+shortPath+'">'+shortName+'</a>',
					iconCls: 'icon-tip',
					onclick:function(){
						var $clickObj = $(this).find("a");
						// 添加快捷菜单单击事件
						var tabId = $clickObj.attr("moduleId");
						$(".tabspage").removeClass("tabspage-2");
				    	tab.addTabItem({tabid : tabId,text: $clickObj.text(), url: $clickObj.attr("path") });
					}
				});
			}
			$("#shortcutEditForm").form('submit',{
	    		url:"<%=application.getContextPath()%>/shorcut/save.do",
	    		data:"shortcutForm.login_id="+user+"&shortcutForm.module_id="+mId+"&shortcutForm.type_id="+typeId+"&shortcutForm.shortcut_name="+shortName+"&shortcutForm.shortcut_path="+shortPath,
	    		success:function(data){
	    			$('#short_win').window('close');
                getShortcut();
                setShortCutLi();
	    		}
	    	})
		});

        $(".side-tt .l-layout-header-toggle,.l-layout-collapse-left-toggle").click(function ()
        {
            if(ShortcutDisplayTip == "show"){
                ShortcutDisplayTip = "hide"
                storeLocal(ShortcutDisplay,ShortcutDisplayTip);
            }else if(ShortcutDisplayTip == "hide"){
                ShortcutDisplayTip = "show";
                delLocalStore(ShortcutDisplay);
            }else{
                ShortcutDisplayTip = "hide"
                storeLocal(ShortcutDisplay,ShortcutDisplayTip);
            }
        });
        if(ShortcutDisplayTip == "hide"){
            ShortcutDisplayTip = "show";
            $(".side-tt .l-layout-header-toggle").click();
        }

		// 加载快捷菜单
		$("div[data-role='accordion']").append($("#sortcutMenu").children().clone());
		
		// 将首页内容tab隐藏
		$(".tabspage").addClass("tabspage-2");
		
		tab = $("div.tabspage").uedGetTabManager({
			 dblClickToClose: true, //是否双击时关闭
        	 dragToMove: true,    //是否允许拖动时改变tab项的位置
        	 contextmenu:true
		});
		
		//切换tab的时候，左边的树自动定位
		tab.bind("afterClickTabItem",function(tabid,sysid){
			if(tabid!='indexpage' && sysid!=undefined){
				var currSysId = $('.l-accordion-header:visible').attr('system_id');
				//if(sysid!=currSysId){
					loadAccordion(sysid,'',false,tabid);
				//}
           	}
           	return false;
        });
		
		//添加快捷菜单
		function addShortMenu(){
			var tabId = tab.getSelectedTabItemID();
			var $tabObj = $("li[tabid='"+tabId+"']");
			tabId = tabId.replace(/___/,'').replace(/sortcut_/,'');
			if(tabId.indexOf('tree')>0)
				tabId = tabId.substring(0,tabId.indexOf('tree'));
			if(tabId!='indexpage'){
				var cfgFlag = false;
				$.each(shortcutMenus,function(idx,item){
					if(item.module_id==tabId){
						cfgFlag = true;
					}
				});
				if(cfgFlag){
					$.messager.alert('快捷菜单已存在','快捷菜单已添加，不能重复添加！');
					return;
				}
				var src=$tabObj.attr("src");
				var name=$tabObj.attr("name");
				$("input[name='shortcutForm.module_id']").val(tabId);
				$("input[name='shortcutForm.shortcut_name']").val(name);
				$("input[name='shortcutForm.shortcut_path']").val(src);
				$("#short_win").show().window({
					width:350,  
				    height:200,  
				    modal:true  
				});
			}else{
				$.messager.alert('首页不能设置为快捷方式','首页不能设置为快捷方式！');
			}
		}
		
    function getSubstr(str,length){
        if(str.length>length)
            return str.substring(0,length);
        else
            return str;
    }
    //快捷菜单滚动控件
    function setShortCutLi(){
        var $shotCutList = $("#shotCutList");
        var $scroolpanel = $(".scroolpanel");
        $scroolpanel.remove();

        $shotCutUl = $('<ul class="end" id="shotCutUl" style="float:left;"></ul>');

        //var $shotCutList = $("#shotCutUl");
        //$("li",$shotCutUl).remove();
        $.each(shortcutMenus,function(idj,shorcutMenu){
            $shotCutUl.append('<li system_id="'+shorcutMenu.module_id+'" style="width:120px" align="center"><div align="center"><a href="#" onclick="showShotTab(this)" module_id='+shorcutMenu.module_id+' shortcut_name='+shorcutMenu.shortcut_name+' shortcut_path='+shorcutMenu.shortcut_path+' title="'+shorcutMenu.shortcut_name+'">'+getSubstr(shorcutMenu.shortcut_name,8)+'</a></div></li>');
        });

        $scroolpanel = $('<div class="scroolpanel"></div>');
        $scroolpanel.append($shotCutUl);
        $shotCutList.append($scroolpanel);

        if(shortcutMenus!=null && shortcutMenus != undefined && shortcutMenus!='')
        {
            clientwidth = $(window).width();
            var w = clientwidth*0.6;
            var num = parseInt(w/120);

            //滚动
            $(".scroolpanel").jCarouselLite({
                btnNext: ".move-right",
                btnPrev: ".move-left",
                circular: false,
                visible: num
            });

            if(shortcutMenus.length<=num){
                $(".move-right").hide();
                $(".move-left").hide();
            }else{
                $(".move-right").show();
                $(".move-left").show();
            }
        }else{
            $(".move-right").hide();
            $(".move-left").hide();
        }
    }

    function getShortcut(){
        $.ajax({
            url:"<%=application.getContextPath()%>/shorcut/queryShortcut.do",
            data:"shortcutForm.login_id="+loginId,
            type:"post",
            async:false,
            success:function(msg){
                shortcutMenus = msg;
            }
        });
    }

		function initMenu(){
			$("#shortmenuShow").empty();
       		$('#shortmenuShow').menu('appendItem', {
				id:'addShortMenu',
				text: '添加',
				iconCls:'icon-add',
				onclick:function(){
					addShortMenu();
				}
			});
			$('#shortmenuShow').menu('appendItem', {
				id:'editShortMenu',
				text: '整理快捷菜单',
				onclick:function(){
					window.showModalDialog("<%=application.getContextPath()%>/shorcut/loadShortcutManange.do","","help:no;scroll:no;status:no;dialogHeight:500px;dialogWidth:400px");
					initMenu();
				}
			});
			
			// 加载菜单选项
        getShortcut();

			$.ajax({
				url:"<%=application.getContextPath()%>/shorcut/queryShortcut.do",
				data:"shortcutForm.login_id="+loginId,
				type:"post",
				async:false,
				success:function(msg){
					shortcutMenus = msg;
				}
			});
			$.ajax({
				url:"<%=application.getContextPath()%>/shorcut/queryShortcutType.do",
				data:"shortcutTypeForm.login_id="+loginId,
				type:"post",
				success:function(msg){
					var $shortmenuShow = $("#shortmenuShow");
					var $shortcutTypeSelect = $("#shortcutTypeSelect");
					$shortcutTypeSelect.empty();
					$shortcutTypeSelect.append("<option value=''>无</option>");
					$.each(msg,function(idx,shortcutType){
						$shortcutTypeSelect.append("<option value='"+shortcutType.type_id+"'>"+shortcutType.type_name+"</option>");
						$('#shortmenuShow').menu('appendItem', {
							id:'type_'+shortcutType.type_id,
							text: shortcutType.type_name,
							iconCls: 'icon-mini-edit'
						});
						
					});
	
					
					$.each(shortcutMenus,function(idj,shorcutMenu){
						if(shorcutMenu.type_id==null || shorcutMenu.type_id==""){
							$('#shortmenuShow').menu('appendItem', {
								text: '<a moduleId="'+shorcutMenu.module_id+'" style="cursor: hand;" path="'+shorcutMenu.shortcut_path+'">'+shorcutMenu.shortcut_name+'</a>',
								iconCls: 'icon-tip',
								onclick:function(){
									var $clickObj = $(this).find("a");
									// 添加快捷菜单单击事件
									var tabId = $clickObj.attr("moduleId");
									$(".tabspage").removeClass("tabspage-2");
							    	tab.addTabItem({tabid : tabId,text: $clickObj.text(), url: $clickObj.attr("path") });
							    	saveLog(tabId,$clickObj.attr("path"));
								}
							});
						}else{
							$.each(msg,function(idx,shortcutType){
								if(shorcutMenu.type_id==shortcutType.type_id){
									var item = $('#shortmenuShow').menu('findItem', shortcutType.type_name);  // find 'Open' item
									$('#shortmenuShow').menu('appendItem', {
										parent: item.target,  // the parent item element
										text: '<a moduleId="'+shorcutMenu.module_id+'" style="cursor: hand;" path="'+shorcutMenu.shortcut_path+'">'+shorcutMenu.shortcut_name+'</a>',
										iconCls: 'icon-tip',
										onclick:function(){
											var $clickObj = $(this).find("a");
											// 添加快捷菜单单击事件
											var tabId = $clickObj.attr("moduleId");
											$(".tabspage").removeClass("tabspage-2");
									    	tab.addTabItem({tabid : tabId,text: $clickObj.text(), url: $clickObj.attr("path") });
									    	saveLog(tabId,$clickObj.attr("path"));
										}
									});
								}
							});
						}
					});

                setShortCutLi();
				}
			});
			$('#shortmenuShow').menu('hide');
		}
		
		
		initMenu();
		
		
		// 添加快捷菜单单击事件
		$("#sortmenu li a").click(function(){
			var tabId = $(this).attr("moduleId");
			$(".tabspage").removeClass("tabspage-2");
	    	tab.addTabItem({tabid : tabId,text: $(this).text(), url: $(this).attr("path") });
	        return this;
	    });
		
		//点击子系统按钮
		$(".right-panel ul li a").click(function(){
            if($.browser.msie && $.browser.version=="7.0"){
                if($(this).attr('class')!='on' && $(this).attr("system_id") != "mainpage"){
                    $("[position=left]").find("[data-role=accordion]").contents().css("display","none");
                    setTimeout(function(){
                        $(".ztree").find("li").css("width",$(".ztree").find("li").css("width"));
                    },1000);
                    setTimeout(function(){
                        $(".ztree").find("li").css("width",$(".ztree").find("li").css("width"));
                    },5000);
                }
            }
			var $clickSystem = $(this);
			$clickSystem.parent().parent().find("a[class='on']").removeClass("on");
			$clickSystem.addClass("on");
			var sys_id = $clickSystem.attr('system_id');
			var sys_name = $clickSystem.text();
			var sys_path = $clickSystem.attr('system_path');
			var target = $clickSystem.attr('module_target');

			if(sys_id=='mainpage'){
				tab.selectTabItem('indexpage');
			} 
			
			if(sys_path!=null && sys_path!="null" && sys_path!="" && target!="tab"){
				window.open(sys_path);
				return;
			}
			//$("div[ref='indexpage']").hide();
			loadAccordion(sys_id,sys_name,true,null);
		});
		
		//查找sysid的accordion
		function findAccordion(sysid){
			return $("div[data-role='accordion'][sysid='"+sysid+"']");
		}
		//将sysid的accordion设为可见，其他accordion隐藏
		function showAccordion(sys_id){
			$accordion = $("div[data-role='accordion']");
            if($.browser.msie && $.browser.version=="7.0"){
               $('.temp-header').removeClass('temp-header').addClass('l-accordion-header');
               $('.temp-content').removeClass('temp-content').addClass('l-accordion-content');
            }
            $(".l-accordion-header",$accordion).each(function(indx,obj){
				var $this = $(this);
				if($this.attr("system_id")==sys_id){
					$this.attr("style","display:block");
				}else{
					$this.attr("style","display:none");
				}
				
			});
			
			$(".l-accordion-content",$accordion).each(function(indx,obj){
				var $this = $(this);
				if($this.attr("system_id")==sys_id){
					if($this.attr("tag")=="open"){
						$this.css("display","block");

						var togglebtn = $(".l-accordion-toggle:first", $this.prev(".l-accordion-header"));
						if (togglebtn.hasClass("l-accordion-toggle-close"))
		                {
		                    togglebtn.removeClass("l-accordion-toggle-close")
		                    .removeClass("l-accordion-toggle-close-over l-accordion-toggle-open-over");
		                    togglebtn.addClass("l-accordion-toggle-open");
	                    }
					}
				}else{
					if($this.css("display")!="none"){
						$this.attr("tag","open");	//设置标记，切换后显示
						$this.css("display","none");
					}
				}

			});

		}
		//隐藏所有accordion
		function hiddenAllAccordion(){
			$accordion = $("div[data-role='accordion']");

			$(".l-accordion-header",$accordion).each(function(indx,obj){
				var $this = $(this);
				$this.attr("style","display:none");
                if($.browser.msie && $.browser.version=="7.0"){
                    $this.removeClass('l-accordion-header').addClass('temp-header');
                    $this.css("zoom","");
                }
            });
			
			$(".l-accordion-content",$accordion).each(function(indx,obj){
				var $this = $(this);
				if($this.css("display")!="none"){
					$this.attr("tag","open");
					$this.css("display","none");
                    if($.browser.msie && $.browser.version=="7.0"){
                        $this.removeClass('l-accordion-content').addClass('temp-content');
                        $this.css("zoom","");
                    }
                }
			});
		}
		
		function showIndexShortcut(isShow){
			$accordion = $("div[data-role='accordion']");
			var str = "display:none";
			if(isShow){
				str = "display:block";
			}
			
			$("p[ref='shortcut']",$accordion).each(function(indx,obj){
				var $this = $(this);
				$this.attr("style",str);
			});
			$("ul[ref='shortcut']",$accordion).each(function(indx,obj){
				var $this = $(this);
				$this.attr("style",str);
			});
		}
		
		//点击子系统加载树形菜单，或者点击打开的tab定位所在的树
		//isExpandFirstNode是否自动展开第一个菜单和展开树第一个节点，true展开，false不展开
		//sys_id 子系统id
		//sys_name 可以为null，会从系统菜单查找name
		//tabid 点子系统菜单是为null，点击tab时传tab的id用于切换tree
		function loadAccordion(sys_id,sys_name,isExpandFirstNode,tabid){
			if(sys_id=='mainpage'){
				$(".side-text").html("快捷栏");
				tab.selectTabItem('indexpage');
				$(".tabspage").addClass("tabspage-2");
				$(".side-tt .l-layout-header-toggle").click();
				//$accordion.append($("#sortcutMenu").children().clone(true));
				$(".l-layout-content2").removeClass("l-layout-content2").addClass("l-layout-content");
				showIndexShortcut(true);
				hiddenAllAccordion();
				return;
			}else{
				$(".tabspage").removeClass("tabspage-2");
				$(".l-layout-collapse-left .l-layout-collapse-left-toggle").click();
				$(".l-layout-content").removeClass("l-layout-content").addClass("l-layout-content2");
				showIndexShortcut(false);
				
				if(sys_name==null||sys_name==''){
					$("a",$(".blue-link")).each(function(idx,obj){
						var $this = $(this);
						if($this.attr('system_id')==sys_id){
							sys_name = $this.text();
						}
					});
				}
				$("span[class='side-text']").html(sys_name);
				
				var $accordion = $("div[data-role='accordion']");
				var $accordionElement = $("div[system_id='"+sys_id+"']",$accordion);
				if($accordionElement.length>0){//如果之前加载过
					showAccordion(sys_id);
					
			        if(tabid!=null&&tabid!=''){	//如果是切换tab，定位tree
						$(".l-accordion-header:visible").each(function(idx ,obj){
				        	var $clickAcdObj = $(this);
							var module_id = $clickAcdObj.attr("module_id");
							
							var $treeUl = $("#tree_"+module_id);
							if($treeUl.html()==null || $treeUl.html()==""){
								loadRootNode($treeUl,module_id,false);
							}
							
							var tree_id = "tree_"+module_id;
				        	var zTree = $.fn.zTree.getZTreeObj(tree_id);
				        	if(zTree!=null){
					        	var node = zTree.getNodeByParam("id", tabid, null);
					        	if(node!=undefined){
					        		var $open = $('.l-accordion-toggle-open',$clickAcdObj).attr("class");
					        		if($open==undefined){
					        			$clickAcdObj.click();
					        		}
					        	}
					        }
			        	});
			        }
				}else{//第一次加载
					
					//var $cont = $(".side-content");
					//$accordion = $("div[data-role='accordion']").children().remove().end();
					//$("div[data-role='accordion']").attr("style","display:none");
					//$accordion = $('<div data-role="accordion" data-rel="active" sysid="'+sys_id+'" class="l-accordion-panel" ueduiid="Accordion1002">');
					//$cont.append($accordion);
					
					hiddenAllAccordion();
					
					var $l_accordion_panel = $accordion;
					// 加载子节点
					$.getJSON("loadAccordionItemByParentId.do?module_id="+ sys_id +"&level=1&date=" + new Date(), 
						function(data){
							var jsonArray = eval(data);
					        $.each(jsonArray, function(i, item){
					        	// 包装ued外层
								var $accordion_header = $('<div class="l-accordion-header"  module_id="'+item.MODULE_ID+'" system_id="'+sys_id+'" path="'+item.MODULE_PATH+'" module_name="'+item.MODULE_NAME+'"></div>');
								var $accordion_header_img = $('<div class="l-accordion-toggle  l-accordion-toggle-close"  module_id="'+item.MODULE_ID+'" ></div>');
								var $accordion_header_inner = $('<div class="l-accordion-header-inner">'+item.MODULE_NAME+'</div>');
								if(item.MODULE_PATH!=null && item.MODULE_PATH!="null" && item.MODULE_PATH!=""){
									$accordion_header_inner = $('<div class="l-accordion-header-inner"><a href="#" onclick="javascript:addSysTab(\''+item.MODULE_ID+'\',\''+item.MODULE_NAME+'\',\''+item.MODULE_PATH+'\',\''+sys_id+'\')">'+item.MODULE_NAME+'</a></div>');
								}
								$accordion_header.append($accordion_header_img).append($accordion_header_inner);
								var $accordion_content = $('<div title="" class="l-accordion-content" style="display:none;" system_id="'+sys_id+'"></div>');
								var $accordion_content_pd = $('<div class="directorytree-1 pd10"><ul style="position:relative;top:0px" id=\"tree_'+item.MODULE_ID+'\" class=\"ztree\"></ul></div>');
								$accordion_content.append($accordion_content_pd);
				                $l_accordion_panel.append($accordion_header).append($accordion_content);
					        });
					        
					        //1、加载它的树节点
					        //2、将它展开
					        $l_accordion_panel.find(".l-accordion-header").each(function(idx ,obj){
					        	$(obj).bind('click',function(){
						        	var $clickAcdObj = $(this);
									var module_id = $clickAcdObj.attr("module_id");
									var path = $clickAcdObj.attr("path");
									if(path!=null&&path!="null"&&path!=""){
										addSysTab(module_id,$clickAcdObj.attr("MODULE_NAME"),path,sys_id);
									}
									var $treeUl = $("#tree_"+module_id);
									if($treeUl.html()==null || $treeUl.html()==""){
										loadRootNode($treeUl,module_id,isExpandFirstNode);
									}
						        });
					        });
					        
					        if(isExpandFirstNode){
						        // 将第一个accordion展开
						        var flag = true;
						        $l_accordion_panel.find(".l-accordion-header").each(function(indx,obj){
						        	var $this = $(this);
						        	if(flag && $this.css("display")!="none"){
						        		$this.click();
						        		flag = false;
						        	}
						        });
					        }
					        //解决菜单太多的时候最下面一个看不到的问题
							if($(".l-accordion-header:visible").length>20){
								var sideH=$(".l-layout-center").height();
								$(".side-content").css('height',sideH-30);
							}
					        
					    }
					 )
					 
					
					//$(".l-accordion-panel").css('height',sideH-10);
				}
			}
		}
		
		$("#editShortMenu").click(function(){
			window.showModalDialog('<%=application.getContextPath()%>/shorcut/loadShortcutManange.do','我的收藏夹','help:no;scroll:no;status:no;dialogHeight:500px;dialogWidth:400px');
		});
		
		$("a[id^=shortmenuBtn]").click(function(){
			var position = $(this).offset();
			 $('#shortmenuShow').menu('show', {
				left: position.left+179,
				top: position.top+30
			 });
            if($(this).attr("id")=="shortmenuBtn"){
                $("#addShortMenu").hide();
                $("#editShortMenu").hide();
            }else{
                $("#addShortMenu").show();
                $("#editShortMenu").show();
            }
		});
		
    var resizeTimer = null;

		$(window).resize(function(){
			var sideH=$(".l-layout-center").height();
			$(".side-content").css('height',sideH-30);
			$(".l-accordion-panel").css('height',sideH-10);

        var width = $(window).width();

        if(width!=clientwidth){
            setShortCutLi();
        }
        //resizeTimer = resizeTimer ? null : setTimeout(setShortCutLi,0);
		});
		
		$(".modal_box_iframe").click(function(){
       		$("#personalize").dialog({  
			    title: '个人设置',  
			    width: 550,  
			    height: 300,  
			    closed: false,  
			    cache: false,  
			    href: 'loadOldInfoOther.do',  
			    modal: true 
			});  
       	});

    $(".person_record").click(function(){
        window.open('http://10.182.15.197:8666/dutyAddressListConfig.do');
    });

    var onlineServerUser = [{loginId:"yangzhi",userName:"管理员1"},{loginId:"mengxy",userName:"管理员2"},{loginId:"other",userName:"其他"}];
       	/*消息中心主要查看系统或个人的消息*/
//       	$('#msgCenter').tooltip({
//			content: $('<div></div>'),
//			showEvent: 'hover',
//			onShow: function(){
//				var t = $(this);
//				t.tooltip('tip').unbind().bind('mouseenter', function(){
//					t.tooltip('show');
//				}).bind('mouseleave', function(){
//					t.tooltip('hide');
//				});
//			},
//			onHide:function(){
//				$(this).children().empty();
//			}
//		});
		
		$('#onlineServer').tooltip({
			content: $('<div></div>'),
			showEvent: 'hover',
			onUpdate: function(content){
				content.empty();
				var $msgSenderUser = $(".online-user").clone(true);
				var $select = $msgSenderUser.find("div[rel='online-content']");
				// 获取和用户交互过的用户信息
				$.each(onlineServerUser,function(idx,ele){
					var $userObj = $("<div style='display:inline-block;cursor:hand;margin-right:5px' rel='"+ele.loginId+"'><div><img src='<%=application.getContextPath()%>/nresources/ued/images/image-4.png' style='width:30px;height:30px' /></div><div>"+ele.userName+"</div></div>");
					$select.append($userObj);
					$userObj.unbind().bind('click',function(){
						var receiver = ele.loginId;
						if(receiver=='other'){
							var selectUser = window.showModalDialog('<%=application.getContextPath()%>/loadUserManage.do?type=select','选择用户','help:no;scroll:no;status:no;dialogHeight:600px;dialogWidth:900px');
					   		if(selectUser!=undefined){
					   			var name = "";
			                    receiver = selectUser[0].LOGIN_ID;
			                    name = selectUser[0].NAME;
			                    onLineMsgShow(loginId,receiver);
							}
						}else{
							onLineMsgShow(loginId,receiver);
						}
					});
					//$select.append("<option value='"+ele.loginId+"'>"+ele.userName+"</option>");
				})
				content.append($msgSenderUser.show());
			},
			onShow: function(){
				var t = $(this);
				t.tooltip('tip').unbind().bind('mouseenter', function(){
					t.tooltip('show');
				}).bind('mouseleave', function(){
					t.tooltip('hide');
				});
			},
			onHide:function(){
				$(this).children().empty();
			}
		});
	})
	// 加载消息设置	
	$.ajax({
		url:"queryMessageSetting.do",
		type:"post",
		success:function(data){
			messageSetting = data;
		}
	});
	
	//保存模块访问日志
	function saveLog(moduleId,path){
		var flag = "sortcut_";
		if(moduleId.indexOf(flag)>=0){
			moduleId = moduleId.substring(moduleId.indexOf(flag)+flag.length);
		}
		$.ajax({
			url:"saveModuleLog.do?moduleId="+moduleId+"&path="+path,
			type:"post",
			success:function(data){
			}
		});
	}

	//加载树 isExpandFirstNode为true展开第一个数 false不展开
	function loadRootNode($treeObj,rootId,isExpandFirstNode){
		$treeObj.html("loading...");
		// 异步加载节点信息
		$.ajax({
			url:"getSubSystemModuleJson.do",
            data: {"node.id":rootId,"viewType":"view"},
			type:"POST",
			success : function(msg){
				$treeObj.html("");
				msg = eval(msg);
				$.fn.zTree.init($treeObj, {
					treeId:"id",
					data: {
						key:{
	                           name:'name',
	                           title:'name',
	                           id:'id'
	                       },
	                       simpleData:{
	                           idKey:'id'
	                       }				
					},
					async:{
						enable:true,
						type:"post",
						dataType:"json",
						autoParam:["id=node.id"],
						url:"getSubSystemModuleJson.do"
					},
					view: {
						fontCss: function (treeId, treeNode) {
							return (!!treeNode.highlight) ? {color:"#A60000", "font-weight":"bold"} : {color:"#333", "font-weight":"normal"};
						},
						dblClickExpand:true
					},
					callback:{
						onClick : function(event, treeId, treeNode){
							//alert(treeNode.tId);
							if(treeNode.userData.PATH==null||treeNode.userData.PATH=="null"||treeNode.userData.PATH=="")
								return;
							if("blank"==treeNode.userData.TARGET){
								window.open(treeNode.userData.PATH);
							}else{
								var tabId = treeNode.id;
								// 添加title
								//addCenterTitle(treeNode,treeId);
								if(!tab.isTabItemExist(tabId)){
									var sysId = $('.l-accordion-header:visible').attr('system_id');
									// 添加tab
									tab.addTabItem({ tabid : tabId,text: treeNode.name, url: treeNode.userData.PATH ,sysid: sysId});
									var $newEle = $("li[tabid=" + tabId + "]");
									$newEle.click(function(){
										var tabIdSplits = $(this).attr("tabid").split("___");
										var seleTreeId = "tree_"+tabIdSplits[0];
										var seleNodeId = tabIdSplits[1];
										//invertTreeNode(seleTreeId,seleNodeId,false);
									});
									saveLog(treeNode.id,treeNode.userData.PATH );
								}else{
									tab.selectTabItem(tabId);
									// 是否刷新tab
									if(treeNode.userData.IS_REFRESH=="1"){
										tab.reload(tabId);
									}
								}
							}
						},
						onNodeCreated:function(event, treeId, treeNode){
							if(isExpandFirstNode){
						        if(treeNode.isFirstNode){	//展开第一个节点
						        	var zTree = $.fn.zTree.getZTreeObj(treeId);
						        	zTree.expandNode(treeNode, true);
						        }
						    }

						}
					}
				}, msg);
			}
		});
	}
	
	// 反选树节点
	function invertTreeNode(treeId,treeNodeId,hasTab){
		// 判断accordion是否被选中
		$(".l-accordion-toggle-close").removeClass('l-accordion-toggle-close').addClass("l-accordion-toggle-open");
		$(".l-accordion-toggle[module_id='"+treeId.replace(/tree_/g,'')+"']").addClass("l-accordion-toggle-close").click();
		//alert($(".l-accordion-toggle").find("div[module_id='"+treeId.replace(/tree_/g,'')+"']"));
		// 对树节点操作
	   	// 首先要选中accordion,然后再对下面的数节点进行操作
		var treeObj = $.fn.zTree.getZTreeObj(treeId);
		var treeNodes = treeObj.getNodes();
		var matchObj = treeObj.getNodeByTId(treeNodeId);
		treeObj.selectNode(matchObj,false);
	}
	
	// 从树中查找到与
	function findMatchTreeNodeByTreeNodeId(treeNode,treeIdx){
		var matchObj;
		if(treeNode.tId==treeIdx){
			return treeNode;
		}else{
			if(treeNode.isParent && treeNode.children){
				var childNodes = treeNode.children;
				for(var idx = 0 ; idx < childNodes.length ; idx ++){
					matchObj = findMatchTreeNodeByTreeNodeId(childNodes[idx],treeIdx);
					if(matchObj!=null){
						break;
					}
				}
			}
		}
		return matchObj;
	}
	
	$(document).ready(function(){
		$(".showMessager").click(function(){
	   		tabId = "showMessager";
	   		tabName = "历史消息";
	   		url = "loadMsgHisList.do";
	   		
			addTab(tabId,tabName,url);
			
		});

        $.ajax({
            url:'<s:url action="getSysDict" namespace="/ibnms/common"/>',
            data:{dict:{dictId:100}},
            async:false,
            success:function(data){
                if(data && data.itemsMap.News && data.itemsMap.News.itemName=='FULL'){
                    loadUnreadNews();
                }else{
                    loadUnreadNews2();
                }
                if(data && data.itemsMap.TreeMenu && data.itemsMap.TreeMenu.itemName=='HIDE'){
                    $(".side-tt .l-layout-header-toggle").click();
                }
            },
            error:function(){
                loadUnreadNews2();
            }
        });

        loadUnreadMsg('auto');
        $(".changeUser").click(function(){
	   		var selectUser = window.showModalDialog('<%=application.getContextPath()%>/loadUserManage.do?type=select','选择用户','help:no;scroll:no;status:no;dialogHeight:600px;dialogWidth:900px');
	   		if(selectUser!=undefined){
	   			var id = "";
	   			var name = "";
	   			for (var one in selectUser){
                   	id = id + selectUser[one].LOGIN_ID + ",";
                }
                if(id.length>0){
                	id = id.substring(0,id.length-1);
                }
                window.location.href = "logout.do?changeUserId="+id;
                <%--$.ajax({--%>
					<%--url:"<%=application.getContextPath()%>/logoutForChangeUser.do",--%>
					<%--type:"post",--%>
					<%--async:false,--%>
					<%--success:function(msg){--%>
						<%--for (var one in msg){--%>
	                    	<%--var PARA_ID = msg[one].PARA_ID;--%>
	                    	<%--var url = msg[one].PARA_VALUE;--%>
	                    	<%----%>
	                    	<%--if (PARA_ID != "FINAL_LOGOUT") {--%>
								<%--var iframe = document.createElement("iframe");--%>
								<%--iframe.src = url;--%>
								<%--iframe.style.display = "none";--%>
								<%--document.body.appendChild(iframe);--%>
							<%--}--%>
	                    <%--}--%>
	                    <%--$.ajax({--%>
							<%--url:"<%=application.getContextPath()%>/changeUser.do",--%>
							<%--data:"loginId="+id,--%>
							<%--type:"post",--%>
							<%--async:false,--%>
							<%--success:function(msg){--%>
								<%--window.location.reload();--%>
							<%--}--%>
						<%--});--%>
					<%--}--%>
				<%--});--%>
			}
		});
		
		//layout resize后，设置高度
		$(window).bind("afterResizeLayout",function(){
			setLayHeight();
	       	return false;
	      });
		
		setLayHeight();
		
	})

function showShotTab(menu){
    //alert(($(menu)).attr('shortcut_path'));
    var $menu = $(menu);
    var id = $menu.attr('module_id');
    var name = $menu.attr('shortcut_name');
    var path = $menu.attr('shortcut_path');
    addTab(id,name,path);
    saveLog(id);
}


	//打开tab，带sysId，用于树定位
	function addSysTab(tabId,tabName,url,sysId){
		if(!tab.isTabItemExist(tabId)){
			// 添加tab
			$(".tabspage").removeClass("tabspage-2");
			setLayHeight();
			tab.addTabItem({ tabid : tabId,text: tabName, url: url ,sysid: sysId});
		}else{
			tab.selectTabItem(tabId);
			tab.reloadUrl(tabId,url);
		}
	}
	
	//设置.l-tab-content高度，否则会出现tab消失的情况
	function setLayHeight(){
		var h1 = $(".l-tab-content").height();
		var h2 = $(".l-tab-links").height();
		$(".l-tab-content").height(h1-h2);
	}
	
	//提供给外部系统的方法 start
	function addTab(tabId,tabName,url){
		if(!tab.isTabItemExist(tabId)){
			// 添加tab
			$(".tabspage").removeClass("tabspage-2");
			setLayHeight();
			tab.addTabItem({ tabid : tabId,text: tabName, url: url });
		}else{
			tab.selectTabItem(tabId);
			tab.reloadUrl(tabId,url);
		}
	}
	function removeTab(tabId){
		if(tab.isTabItemExist(tabId)){
			tab.removeTabItem(tabId);
		}
	}
	
	function refreshPanel(panelId){
		var $iframe = $("#panelfrm").contents().find("#"+panelId+" iframe");
		$iframe.attr("src",$iframe.attr("src"));
	}
	
	function autoHeight(panelId,iframe_height){
		if(iframe_height!="0"){
			var $newbox = $("#panelfrm").contents().find("#"+panelId);
			var $ttcorner = $(".newbox-tt",$newbox);
			var $newboxArea = $(".newbox-area",$newbox);

			var ttHeight = $ttcorner.height();
			var h = parseInt(iframe_height) + parseInt(ttHeight);
			$newbox.attr({style:"height:"+h+"px"});
			$newboxArea.attr({style:"height:"+iframe_height+"px"});
		}
	}
	//提供给外部系统的方法 end
</script>